package video.local.analyse.cluster;

import java.io.IOException;
import java.sql.*;
import video.local.VideoBasicMethodsSet;


public class InsertSimilitude {
	private String videoAddr1 = null;
	private String videoAddr2 = null;
	private String videourl1 = null;
	private String videourl2 = null;
	private int id1 = 0;
	private int id2 = 0;
	Connection conn = null;
	Statement stmt1 = null;
	Statement stmt2 = null;
	ResultSet rtstCluster = null;
	ResultSet rtstBaidu_lr = null;
	String queryCluster = "select * from cluster";
	
	String url = "jdbc:MySQL://192.168.1.213/videose?user=root&password=ladjzero";

	public void getVideoAddr(){
		try{
			Class.forName("com.mysql.jdbc.Driver");
				conn = DriverManager.getConnection(url);
				stmt1 = conn.createStatement();
				stmt2 = conn.createStatement();
				rtstCluster = stmt1.executeQuery(queryCluster);

				while(rtstCluster.next()){
					id1 = Integer.parseInt(rtstCluster.getString("id1"));
					//System.out.println("id1:" + id1);
					id2 = Integer.parseInt(rtstCluster.getString("id2"));
					String queryBaidu_lr1 = "select * from baidu_lr where id = " + id1;
					String queryBaidu_lr2 = "select * from baidu_lr where id = " + id2;
					rtstBaidu_lr = stmt2.executeQuery(queryBaidu_lr1);
					if(rtstBaidu_lr.next()){
						videourl1 = rtstBaidu_lr.getString("url");
					}
					rtstBaidu_lr = stmt2.executeQuery(queryBaidu_lr2);
					if(rtstBaidu_lr.next()){						
						videourl2 = rtstBaidu_lr.getString("url");
					}
					try {
						new VideoBasicMethodsSet();
						videoAddr1 = VideoBasicMethodsSet.getVideoPathByVideoPageUrl(videourl1);
						videoAddr2 = VideoBasicMethodsSet.getVideoPathByVideoPageUrl(videourl2);
					} catch (IOException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
					
					
					System.out.print("id1:" +id1 + "  "+ videourl1 + " VideoPATH: ");
					System.out.print(videourl1);
					System.out.print("id2:" + id2 + "  " + videourl2 + " VideoPATH ");		
					System.out.println(videourl2);
				}
				
		}catch(SQLException e){
				e.printStackTrace();
		}
		catch(ClassNotFoundException e){
			e.printStackTrace();
		}	
	}
}
